@extends('layouts.admin_common') @section('content')

    @if(app('env')=='production')
        <script src="{{ secure_asset('/js/sy_common.js') }}"></script>
        <script src="{{ secure_asset('/js/validator.min.js') }}"></script>
    @else
        <script src="{{ asset('/js/sy_common.js') }}"></script>
        <script src="{{ asset('/js/validator.min.js') }}"></script>
    @endif

    <style>
        .layui-layer-btn .layui-layer-btn1 {
            color: #333!important;
        }
    </style>

    <div class="breadcrumbs_container">{{
	Breadcrumbs::render('admin.income_money') }}</div>
    <div class="system_tab_line"></div>

    <div class="lyx_search_table">
        <form>

            <div class="row">
                <div class="form-group row col-sm-4">
                    <label for="inputPassword" class="col-sm-4 col-form-label">入金区分</label>
                    <div class="col-sm-8">
                        <select class="form-control" id="exampleFormControlSelect1" name="state">
                            <option value="1" {{$state == 1 ? 'selected' : ''}} >未入金</option>
                            <option value="0" {{$state == '0' ? 'selected' : ''}} >入金済</option>
                        </select>
                    </div>
                </div>
            </div>


            <div class="row">

                <div class="form-group row col-sm-4">
                    <label for="inputPassword" class="col-sm-4 col-form-label">請求日</label>
                    <div class="col-sm-8">
                        <input class="form-control lyx_datetimepicker" type="text" value="{{$star_date}}" name="star_date">
                    </div>
                </div>

                <div class="form-group row col-sm-4">
                    <label for="inputPassword" class="col-sm-1 col-form-label">~</label>
                    <div class="col-sm-8">
                        <input class="form-control lyx_datetimepicker" type="text" value="{{$end_date}}" name="end_date">
                    </div>
                </div>

            </div>

            <div class="row">
                <div class="col-sm-6"></div>
                <div class="col-sm-3">
                    <button class="btn btn-primary button_normal">检索</button>
                </div>
            </div>



        </form>


        <div class="lyx_table">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th scope="col">請求No.</th>
                    <th scope="col">請求先</th>
                    <th scope="col">出荷日</th>
                    <th scope="col">請求日</th>
                    <th scope="col">請求金額</th>
                    <th scope="col">入金日</th>
                    <th scope="col">入金額</th>
                </tr>
                </thead>
                <tbody>
                @foreach($orderList as $value)
                <tr>
                    <td>{{$value->order_id}}</td>
                    <td>{{$value->name}}</td>
                    <td>{{$value->send_goods_time}}</td>
                    <td>{{$value->create_time}}</td>
                    <td>¥{{$value->send_goods_total_money}}</td>
                    <td>{{$value->in_money_date}}</td>
                    <td><input type="number" class="form-control lyx_in_money" value="" data-order_id="{{$value->order_id}}"></td>
                </tr>
                @endforeach

                </tbody>
            </table>
        </div>

    </div>

<script>
    $(function () {
        $('.lyx_in_money').change(function () {
            var money = $(this).val();
            var order_id = $(this).data('order_id');
            var v = new Validator();
            if(!v.isMoney(money)){
                layuiTopMsg('数字を入力するしかない');
                return false;
            }

            layer.open({
                content: '変更金額を確定しますか？',
                scrollbar: false,
                yes: function(index){
                    setOrderMoney(money,order_id);
                    layer.close(index);
                }
            });
        })


        function setOrderMoney(money,order_id) {
            hdAjax({
                url:'set_order_in_money',
                data:{money:money,order_id:order_id},
                success:function (retData) {
                    if(retData.code == 1001){
                        successAlert(retData.msg,'home');
                    }else{
                        layuiTopMsg(retData.msg);
                    }
                }
            })
        }

    })
</script>
@endsection

